package cn.ezios.huo.system.dao.mapper;

import cn.ezios.huo.system.dao.domain.SysRoleMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 王坚
* @description 针对表【sys_role_menu(系统角色菜单)】的数据库操作Mapper
* @createDate 2024-07-17 09:49:16
* @Entity cn.ezios.huo.dao.domain.SysRoleMenu
*/
public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {

    @Select("SELECT menu_id FROM sys_role_menu AS menu01 WHERE role_id = #{roleId} AND NOT EXISTS ( SELECT parent_id FROM sys_menu AS menu02 WHERE menu01.menu_id = menu02.parent_id )")
    List<String> getRoleMenuLeafIds(String roleId);

    @Select({"<script>" +
            "SELECT DISTINCT menu_id FROM sys_role_menu " +
            "WHERE " +
            "role_id in " +
                "<foreach collection='roleIds' item='roleId' open='(' separator=',' close=')'>" +
                    "#{roleId}" +
                "</foreach>" +
            "</script>"})
    List<String> getMenuIdsByRoleIds(@Param("roleIds") List<String> roleIds);
}




